class Solution {
public:
    int eraseOverlapIntervals(vector<vector<int>>& intervals) {
        sort(intervals.begin(),intervals.end());
        int ret=0;
        int left=intervals[0][0],right=intervals[0][1];
        for(int i=1;i<intervals.size();i++)
        {
            int a=intervals[i][0],b=intervals[i][1];
            if(a<right)
            {
                ret++;
                right=min(right,b);
            }
            else
            {
                right=b;
            }
        }
        return ret;
    }
};
